﻿/*
 * @Autor: PK
 * @Date: 2022/01/11 20:34:SS
 */

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using PropertyChanged;
using ShkSimulation.core.factory;
using ShkSimulation.desktop.Annotations;
using static ShkSimulation.carsharing.impl.create.StationFactory;

namespace ShkSimulation.desktop.setting.model {

	[AddINotifyPropertyChangedInterface]
	public class StationConfigModel: INotifyPropertyChanged {
		
		public StationConfigModel() {
		}
		
		public StationConfigModel(int id) {
			this.Id = id;
			this.Name = id.ToString();
		}

		public StationConfigModel(CreateParam param) {
			this.Id = Convert.ToInt32(param[StationId]);
			this.Name = Convert.ToString(param[StationName]);
			this.VehicleCount = Convert.ToInt32(param[StationVehicleCount]);
			this.Capacity = Convert.ToDouble(param[StationCapacity]);
			this.ServiceMinutes = Convert.ToDouble(param[StationServiceMinutes]);
			this.Longitude = Convert.ToDouble(param[StationLongitude]);
			this.Latitude = Convert.ToDouble(param[StationLatitude]);
			this.DispatcherCount = Convert.ToInt32(param[StationDispatcherCount]);
		}
		
		public int Id { get; set; }
		public string Name { get; set; }
		public double Capacity { get; set; }
		public int VehicleCount { get; set; }
		public double ServiceMinutes { get; set; }
		public double Longitude { get; set; }
		public double Latitude { get; set; }
		public int DispatcherCount { get; set; }

		public event PropertyChangedEventHandler PropertyChanged;

		[NotifyPropertyChangedInvocator]
		protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
			PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
		}

		public override string ToString() {
			return $"Id: {Id}, Name: {Name}, Capacity: {Capacity}, VehicleCount: {VehicleCount}, ServiceMinutes: {ServiceMinutes}, Longitude: {Longitude}, Latitude: {Latitude}, DispatcherCount: {DispatcherCount}";
		}

	}

}